package com.lanou.activity.Service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lanou.activity.Service.SLGFService;
import com.lanou.activity.mapper.SLGFMapper;
import com.lanou.activity.utils.Constant;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class SLGFServiceImpl implements SLGFService{

    @Resource
    private SLGFMapper slgfMapper;


    /**
     * @description 查询促销条件表的促销条件编号conNo和促销条件名称conName
     * @author Lonely
     * @date 17/9/22
     * @return Map<String,Object>/>
     * @param
     */
    @Override
    public List<Map<String, Object>> findSaleCdnInfo() {
        return slgfMapper.findSaleCdnInfo();
    }

    /**
     * @description 添加买赠信息
     * @author Lonely
     * @date 17/9/23
     * @return
     * @param params
     */
    @Override
    public int addSLGFInfo(Map<String, Object> params) {
        return slgfMapper.insertSLGFInfo(params);
    }

    /**
     * @description 查询买赠信息表的信息
     * @author Lonely
     * @date 17/9/25
     * @return
     * @param
     */
    @Override
    public PageInfo<Map<String, Object>> selectSLGFInfo(Map<String,Object> params) {
        System.out.println("params.get(\"currentPage\") = "+params.get("currentPage"));
        Integer currentPage = params.get("currentPage") == null ? 1:Integer.parseInt((String)params.get("currentPage"));
        PageHelper.startPage(currentPage, Constant.CURRENTPAGE);
        List<Map<String,Object>> list = slgfMapper.selectSLGFInfo(params);
        //用PageInfo对结果进行包装
        PageInfo<Map<String,Object>> page = new PageInfo<Map<String,Object>>(list);
        //测试PageInfo全部属性
        return page;
    }

    /**
     * @description 根据买赠id查询买赠信息详情
     * @author Lonely
     * @date 17/9/26
     * @return
     * @param
     */
    @Override
    public Map<String, Object> selectSLGFDetailInfo(int id) {
        return slgfMapper.selectSLGFDetailInfo(id);
    }

    /**
     * @description  修改买赠信息
     * @author Lonely
     * @date 17/9/26
     * @return
     * @param
     */
    @Override
    public int updateSLGFInfo(Map<String, Object> params) {
        return slgfMapper.updateSLGFInfo(params);
    }

    /**
     * @description 查询商品分类表的prdNo和prdName
     * @author Lonely
     * @date 17/9/26
     * @return
     * @param
     */
    @Override
    public List<Map<String, Object>> selectPrdInfo() {
        return slgfMapper.selectPrdInfo();
    }
}
